<!--
/**************************************************
* @ balancepayrecvmanage.jsp
*
* Copyright   2006 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/05/16, Jenny Li
*  1) first release
/**************************************************
-->
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<title>应收应付管理</title>
	<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>		
	<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
	<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
	<%
		HashMap tMap = (HashMap)request.getAttribute("orderdept");
		ArrayList tOrderDeptList = (ArrayList)tMap.get("organization");
		ResultProcess tBalanceMsg = (ResultProcess)request.getAttribute("balpayreclist");
		String tRequery = (String)request.getAttribute("requery");
		ArrayList tPayRecvList = (ArrayList)request.getAttribute("curmonthpayrecvamt");
		String tPayAmt = "";
		String tRecAmt= "";
		if(tPayRecvList!=null){
			tPayAmt = (String)tPayRecvList.get(0);
			tRecAmt = (String)tPayRecvList.get(1);		
		}
	%>	
	<script>
	var counter;
	function process(val){
		if(val == 'Q'){
			balpayrecvmanage.action = "<%=response.encodeURL(root + "/A180302.do")%>";
    		balpayrecvmanage.submit();			
		}else if(val == 'C'){
			balpayrecvmanage.orderDeptId.value="0000";
			balpayrecvmanage.provider.value="";
			balpayrecvmanage.balanceType.value="0";
			balpayrecvmanage.payType.value="0";
			balpayrecvmanage.status.value="00";
			balpayrecvmanage.payRecvStrDate.value = "";
			balpayrecvmanage.payRecvEndDate.value = "";
		}else if(val == 'A'){
			var url = "<%=response.encodeURL(root + "/A180304.do")%>";
			result = showModalDialog(url, window,"status:no;unadorned:no;dialogWidth:900px;dialogHeight:1200px;help:yes;");
			if(result != null ){
				balpayrecvaddform.addDeptId.value = result[0];		
				balpayrecvaddform.addProvider.value = result[1];				
				balpayrecvaddform.addDeptCategory.value = result[2];	
				var ym = result[3];
				if(result[4].length < 2){
					ym = ym + "0" + result[4];
				}else{
					ym = ym + result[4]
				}
				balpayrecvaddform.addBalanceYM.value = ym;
				balpayrecvaddform.addFeeTypeNo.value = result[5];
				balpayrecvaddform.addPayType.value = result[6];
				balpayrecvaddform.addSum.value = result[7];
				balpayrecvaddform.addNotes.value = result[8];
				balpayrecvaddform.addPayDate.value = result[9];
				balpayrecvaddform.addPrincipal.value = result[10];
				//保存查询参数
				balpayrecvaddform.orderDeptId.value = balpayrecvmanage.orderDeptId.value;
				balpayrecvaddform.provider.value = balpayrecvmanage.provider.value;
				balpayrecvaddform.payType.value = balpayrecvmanage.payType.value;
				balpayrecvaddform.balanceType.value = balpayrecvmanage.balanceType.value;
				balpayrecvaddform.status.value = balpayrecvmanage.status.value;
				balpayrecvaddform.payRecvStrDate.value = balpayrecvmanage.payRecvStrDate.value;
				balpayrecvaddform.payRecvEndDate.value = balpayrecvmanage.payRecvEndDate.value;
				balpayrecvaddform.action = "<%=response.encodeURL(root + "/A180305.do")%>";
				balpayrecvaddform.submit();
			}
		}
	}
	function update(obj1,obj2,obj3,obj4){
		if(obj1.value == "修改"){
			obj1.value  = "保存";
			obj3.disabled = false;
			obj4.disabled = false;
			return;
		}else {
			if(isEmpty(obj3.value)){
				alert("收款日期必填!");
				return false;
			}
			if(isEmpty(obj4.value)){
				alert("负责人必填！");
				return false;			
			}
			var str = obj4.value;
			if (StrLen(str)>20)
			{
				alert("负责人长度不能超过10个汉字！");
				return false;
			}

			if(confirm("是否确定信息修改？")){
				balpayrecvmangeform.deptId.value = obj2[1];
				balpayrecvmangeform.deptCategory.value = obj2[2];
				balpayrecvmangeform.balanceYM.value = obj2[0];
				balpayrecvmangeform.feeTypeNo.value = obj2[3];
				balpayrecvmangeform.receiveable.value = obj2[4];
				balpayrecvmangeform.payDate.value = obj3.value;																
				balpayrecvmangeform.principal.value = obj4.value;					
				balpayrecvmangeform.orderDeptId.value = balpayrecvmanage.orderDeptId.value;					
				balpayrecvmangeform.provider.value = balpayrecvmanage.provider.value;					
				balpayrecvmangeform.balanceType.value = balpayrecvmanage.balanceType.value;					
				balpayrecvmangeform.payType.value = balpayrecvmanage.payType.value;					
				balpayrecvmangeform.status.value = balpayrecvmanage.status.value;					
				balpayrecvmangeform.payRecvStrDate.value = balpayrecvmanage.payRecvStrDate.value;					
				balpayrecvmangeform.payRecvEndDate.value = balpayrecvmanage.payRecvEndDate.value;																				
				balpayrecvmangeform.action = "<%=response.encodeURL(root + "/A180303.do")%>";
				balpayrecvmangeform.submit();
			}else{
				return ;
			}
		}
	}
	function isRequery(){
			<%
				if(tRequery != null && tRequery.equals("true")){
			%>
			balpayrecvmanage.action = "<%=response.encodeURL(root + "/A180302.do")%>";
    		balpayrecvmanage.submit();			
			<%		
				}
			%>
	}
	</script>
	</head>
	<body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="isRequery()">
		<form name="balpayrecvmanage" method="get">
			<p><FONT face="宋体"></FONT><FONT face="宋体"></FONT><br>
			</p>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
				<tr>
					<td height="20">
						<table width="100%" border="0" cellspacing="0" cellpadding="1">
							<tr height="20">
								<td height="30" width="758" class="mtxt_black">应收应付管理
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="bg_line" height="2"></td>
				</tr>
			</table>
			<br>
			<table class="bg_table" id="Table1" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px" cellSpacing="1"
				cellPadding="0" width="98%" align="center" border="0">
				<TR height="20">
					<TD class="bg_column" align="center" width="10%">订货单位</TD>
					<TD class="bg_row_odd" width="30%">
						<select name="orderDeptId">					
						<option value="0000">---全部---</option>
						<%
							String tOrderDept = request.getParameter("orderDeptId");
							if(tOrderDeptList != null && tOrderDeptList.size() > 0 ){	
							    if(tOrderDept != null && tOrderDept.equals("0000")){
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
						%>
										<option value="<%=temp[0]%>"><%=temp[1]%></option>						
						<%			    
									}
							    }else{
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
										if(tOrderDept != null && tOrderDept.equals(temp[0])){
							%>
											<option value="<%=temp[0]%>" selected>
											<%=temp[1]%></option>
							<%				    
										}else{
							%>
											<option value="<%=temp[0]%>"><%=temp[1]%></option>
							<%			
										}
									}
							    }
							}

						%>
						</select>					

					</TD>
					<TD class="bg_column" align="center" width="20%">供应商</TD>
					<TD class="bg_row_odd" width="40%">
					<INPUT type="text" name="provider" maxlength="20" value="<%=request.getParameter("provider")== null?"":request.getParameter("provider")%>">（简称完全匹配）
					</TD>
				</TR>
				<TR height="20">
					<TD class="bg_column" align="center" width="10%">结算对象类型</TD>
					<TD class="bg_row_odd" width="30%">
						<select id="Select4" name="balanceType">
							<option value="0" >--全部--</option>							
							<%
								String balType = request.getParameter("balanceType");
								String[][] tRs = GSBaseManager.getAllBalanceType();
								for(int i=0; i < tRs.length; i++){
								    String[] temp = tRs[i];
								    if(balType != null && balType.equals(temp[0])){
							%>
							<option value="<%=temp[0]%>" selected><%=temp[1]%></option>								
							<%
								    }else{
							%>
							<option value="<%=temp[0]%>"><%=temp[1]%></option>							
							<%	    
								    }
								}
							%>
						</select>
					</TD>
					<TD class="bg_column" align="center" width="20%">收付款类型</TD>
					<TD class="bg_row_odd" width="40%"><select id="Select6" name="payType">
							<option value="0" selected>--全部--</option>
							<%
								String payTp = request.getParameter("payType");
								tRs = GSBaseManager.getAllPayType();
								for(int i=0; i < tRs.length; i++){
								    String[] temp = tRs[i];
								    if(payTp != null && payTp.equals(temp[0])){
							%>
									<option value="<%=temp[0]%>" selected><%=temp[1]%></option>								    	
							<%
								    }else{
							%>
									<option value="<%=temp[0]%>"><%=temp[1]%></option>							
							<%	    }
								}
							%>
						</select>
					</TD>
				</TR>
				<tr height="20">
					<TD class="bg_column" align="center" width="10%">状态</TD>
					<TD class="bg_row_odd" width="30%">
					<select id="Select5" name="status">
							<option value="00" selected>--全部--</option>
							<%
								String tStauts = request.getParameter("status");
								tRs = GSBaseManager.getAllUnPayStatus();
								for(int i=0; i < tRs.length; i++){
								    String[] temp = tRs[i];
								    if(tStauts != null && tStauts.equals(temp[0])){
							%>
									<option value="<%=temp[0]%>" selected><%=temp[1]%></option>	
							<%	    	
								    }else{
							%>
									<option value="<%=temp[0]%>"><%=temp[1]%></option>							
							<%	    
								    }
								}
							%>
						</select>
					</TD>
					<TD class="bg_column" align="center">收/付款日期</TD>
					<TD class="bg_row_odd">
						<input id="Text27" name='payRecvStrDate' readonly onfocus='setday(this)' value='<%=request.getParameter("payRecvStrDate")==null?"":request.getParameter("payRecvStrDate")%>'> ～ <input id="Text4" name='payRecvEndDate' readonly onfocus='setday(this)' value="<%=request.getParameter("payRecvEndDate")==null?"":request.getParameter("payRecvEndDate")%>" >											
					</TD>
				</tr>
			</table>
            <%if(tBalanceMsg != null){
                int totalRecords = 0;
                if(request.getAttribute("totalRecords")!=null){
                    totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                }
                int defaultPageSize =10;
                if(request.getAttribute("pageSize")!=null){
                    defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                }
            %>
            <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'></page:pager>
            <%} %>
		</form>
		<p align="center">
			<INPUT type="button" value="查询" class="kuang" ID="Button1" NAME="Button1" onclick="process('Q')">&nbsp;&nbsp;
			<INPUT type="button" value="清空" ID="Button2" NAME="Button2" class="kuang" onClick="process('C')">
		</p>
<%
	ArrayList tList = new ArrayList();
	if(tBalanceMsg != null){
	    
%>

    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
    <td>
            <form name="pager">
			 <input type="hidden" name="deptId">											
			 <input type="hidden" name="balanceYM">	
			 <input type="hidden" name="deptCategory">				 		
			 <input type="hidden" name="orderDeptId">
			 <input type="hidden" name="provider">
			 <input type="hidden" name="balanceType">
			 <input type="hidden" name="payType">
			 <input type="hidden" name="status">
			 <input type="hidden" name="payRecvStrDate"> 			 
			 <input type="hidden" name="payRecvEndDate"> 			 			 
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
            	<tbody>
			<tr class="bg_column" height="20">
				<td class="top" align="center" colSpan="11"><b>对帐单信息列表</b>
				</td>
			</tr>
			<tr class="bg_column" height="20">
				<td class="top" align="right" colSpan="11">
				<!--如果选择了"收/付款日期"的查询条件，则根据收付款日期来统计应收应付总额，否则统计所有应收应付总额-->
				应收款总计: <%=tRecAmt%>元  应付款总计:<%=tPayAmt%>元
				</td>
			</tr>			
			<%
				tList = tBalanceMsg.getAllRecoreds();
				if(tList != null && tList.size() > 0){
			%>
				<tr class="bg_column" height="20">
					<td align="right" colSpan="11">
		    			<page:navigator type='text' queryForm="balpayrecvmanage"/>					
					</td>
				</tr>		    		
			<%    
				}
			%>

			<tr class="bg_column" height="20">
				<td class="top" align="center">
					<div class="txt_content" align="center"></div>
				</td>
				<td class="top" align="center">
					<div class="txt_content" align="center">公司名称</div>
				</td>
				<td class="top" align="center">
					<div class="txt_content" align="center">公司类型</div>
				</td>
				<td class="top" align="center">
					<div class="txt_content" align="center">费用类型</div>
				</td>				
				<td class="top" align="center">
					<div class="txt_content" align="center">收付款类型</div>
				</td>				
				<td class="top" align="center">
					<div class="txt_content" align="center">金额</div>
				</td>				
				<td class="top" align="center">
					<div class="txt_content" align="center">已完成金额（元）</div>
				</td>				
				<td class="top" align="center">
					<div class="txt_content" align="center">剩余金额（元）</div>
				</td>				
				<td class="top" align="center">
					<div class="txt_content" align="center">收款日期</div>
				</td>
				<td class="top" align="center">
					<div class="txt_content" align="center">负责人</div>
				</td>
				<td class="top" align="center">
					<div class="txt_content" align="center">状态</div>
				</td>
			</tr>
			<%
				if(tList != null && tList.size() > 0){
				    String temp = "";
				    for(int i=0; i<tList.size(); i++){
				        
				        String tStr[] = (String[])tList.get(i);
				        String trClass = "";
						if(i%2==0){
						    trClass="bg_row_odd";
						}else {
						    trClass="bg_row_even";
						}
			%>
							<tr class="<%=trClass%>" height=20>															 
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
									<script>
										var tVal<%=i%> = new Array();
										tVal<%=i%>[0] = '<%=tStr[0]%>';
										tVal<%=i%>[1] = '<%=tStr[1]%>';										
										tVal<%=i%>[2] = '<%=tStr[3]%>';										
										tVal<%=i%>[3] = '<%=tStr[4]%>';	
										tVal<%=i%>[4] = '<%=tStr[13]%>'
									</script>
									<input type="button" class="kuang" value="修改" onClick="update(this,tVal<%=i%>,document.pager['payDate<%=i%>'],document.pager['principal<%=i%>']);">
									</div>
								</td>								
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=tStr[2] %>									
									</div>
								</td>						
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=GSBaseManager.getBalanceDeptTypeName(tStr[3])%>									
									</div>
								</td>						
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=tStr[12]%>
									</div>
								</td>														
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=GSBaseManager.getPayTypeName(tStr[5])%>
									</div>
								</td>				
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=tStr[6]%>									
									</div>
								</td>														
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=tStr[7]%>									
									</div>
								</td>														
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=tStr[8]%>									
									</div>
								</td>			
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<input type="text" name="payDate" id="payDate<%=i%>" value="<%=tStr[9]%>" onfocus='setday(this)' disabled><font color="red">*</font>									
									</div>
								</td>		
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<input type="text" name="principal" id="principal<%=i%>" value="<%=tStr[10]%>" disabled><font color="red">*</font>									
									</div>
								</td>		
								<td class=top align=middle> 	
									<div align="center" class="txt_content">
										<%=GSBaseManager.getPayStatusName(tStr[11])%>									
									</div>
								</td>																																						
							</tr>
			<%				
				    }
			%>
							<tr class="bg_column" height="20">
								<td colspan="11" align="right">
						    		<page:navigator type='text' queryForm="balpayrecvmanage"/>
								</td>
							</tr>
			<%	    
				}else{
			%>
							<font color="red">没有符合条件的对帐单信息</font>
			<%				    
				}
			%>
			</tbody>
			</table>
			</form>
			</td>
			</tr>
		</table>
				<p align="center">
				<table>
				<tr>
					<td align="center">
						<INPUT type="button" value="新增" class="kuang" onClick="process('A')">						
						<br>
					</td>
				</tr>
				</table>
				</p>			
<%	    
	}
	if(tBalanceMsg == null && tRequery != null && tRequery.equals("true")){
%>
	    	<font size="2">数据查询中......</font>
<%
   	}
%>		

<form name="balpayrecvmangeform" method="post">
	<input type="hidden" name="deptId">
	<input type="hidden" name="balanceYM">
	<input type="hidden" name="deptCategory">
	<input type="hidden" name="feeTypeNo">
	<input type="hidden" name="payDate">
	<input type="hidden" name="principal">
	<input type="hidden" name="receiveable">
	<!-- 查询参数 -->
	<input type="hidden" name="orderDeptId">
	<input type="hidden" name="provider">
	<input type="hidden" name="balanceType">
	<input type="hidden" name="payType">
	<input type="hidden" name="status">
	<input type="hidden" name="payRecvStrDate">
	<input type="hidden" name="payRecvEndDate">		
</form>
<form name="balpayrecvaddform" method="post">
	<input type="hidden" name="addDeptId">	
	<input type="hidden" name="addBalanceYM">
	<input type="hidden" name="addFeeTypeNo">
	<input type="hidden" name="addProvider">
	<input type="hidden" name="addDeptCategory">
	<input type="hidden" name="addPayType">
	<input type="hidden" name="addPayDate">	
	<input type="hidden" name="addPrincipal">	
	<input type="hidden" name="addSum">
	<input type="hidden" name="addNotes">	
	<!-- 查询参数 -->
	<input type="hidden" name="orderDeptId">
	<input type="hidden" name="provider">
	<input type="hidden" name="balanceType">
	<input type="hidden" name="payType">
	<input type="hidden" name="status">
	<input type="hidden" name="payRecvStrDate">
	<input type="hidden" name="payRecvEndDate">	
</form>

</body>
</html>


